Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safety fixes and docs for vtab #415

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

sourcefrog
Copy link

The vtab methods are called with pointers to uninitialized blocks of memory:

  • The docs previously seemed to falsely indicate that these blocks were actually initialized: clarify the docs.

  • It's UB to read uninitialzed memory, and better to write it with ptr::write. In particular, less trivial code that follows the example can corrupt memory if it uses the patterns shown in the example.

  • Use unsafe blocks inside unsafe fns in the example, because this will be a warning in Rust 2024. In particular, do this to avoid a warning from the duckdb_entrypoint macro.

  • The Rust types used in the examples don't need layout compatibility with C, and can simply be Rust structs using native strings.

Improves #414

This will prevent the macro generating a warning in edition 2024
Contrary to the previous docs, the instances passed to these functions are *not* initialized by the caller. Rather, the called function is responsible for writing into uninitialized memory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant